package com.sleep.myutilsspringbootstarter.config;

import com.sleep.myutilsspringbootstarter.service.MyUtilService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;

/**
 * @ClassName MyUtilsConfig
 * @Description TODO
 * @Author 郭敖
 * @Date 2024年03月23日 19:56
 * @Version 1.0
 */
@AutoConfiguration
@EnableConfigurationProperties(value = MyUtilsConfig.class)
@ConditionalOnClass(MyUtilService.class)
@ConditionalOnProperty(name = "myutils.enable", havingValue = "true", matchIfMissing = true)
@Slf4j
public class MyUtilsConfig {
    @Autowired
    private MyUtilsProperties properties;

    @Bean
    public MyUtilService myUtilService()
    {
        MyUtilService myUtilService = new MyUtilService();
        log.warn("myutilService:{}",properties);
        return myUtilService;
    }
}
